﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using BUS;
using DAO;
using DTO;

namespace BUS
{
    public class HocSinhBUS
    {
        #region Them Hoc Sinh
        public static bool ThemHocsinh(  string hoTen, DateTime ngaySinh, string  diaChi, string gioiTinh )
        {

            HocSinhDTO hocSinh  = new HocSinhDTO( hoTen, ngaySinh, diaChi, gioiTinh  );
            if( HocSinhDAO.insert( hocSinh ) )
                return true;
            return false;
        }
        #endregion

        #region Tra Cuu Hoc Sinh
        public static DataTable TraCuuMaHocSinh(string maHocSinh)
        {
            DataTable tb = HocSinhDAO.TraCuuMaHocSinh( maHocSinh );
            return tb;
        }

        public static DataTable TraCuuTenHocSinh(string tenHocSinh)
        {
            DataTable tb = HocSinhDAO.TraCuuTenHocSinh(tenHocSinh);
            return tb;
           
        }
        #endregion

        public static bool ThemVaoLop(string maHocSinh, string maLop, string chucVu)
        {
            DataTable tb = HocSinhBUS.BangDanhSachLop(maLop);
            
            if (tb.Rows.Count == QuyDinhBUS.GetSiSo()  || HocSinhBUS.KiemTraMaHocSinh(maHocSinh) == false)
            {   
                return false;
            }
          return   HocSinhDAO.ThemVaoLop( maHocSinh, maLop, chucVu );   
        }

        public static bool KiemTraMaHocSinh(string maHocSinh)
        {
            DataTable tb = new DataTable();

            tb = HocSinhDAO.TraCuuMaHocSinh( maHocSinh );

            if (tb.Rows.Count == 0)
                return false;
            else
                return true;
        }

         public static DataTable BangDanhSachLop(string maLop)
        {
            return HocSinhDAO.BangDanhSachLop( maLop );
        }
    }
}
